package jmine.tec.proxy.chain;

import java.lang.reflect.Method;

/**
 * Represents a method invocation chain.
 * 
 * @author takeshi
 * 
 */
public interface InvocationChain {

    /**
     * Gets the bean on witch the method will be invoked. Invocation on this
     * bean will not inccur reinvocation of the invocation chain.
     * 
     * @return {@link Object}
     */
    Object getBean();

    /**
     * Gets the params used to invoked this method. Changes on this array will
     * affect the parameters used to invoke the method.
     * 
     * @return array of {@link Object}
     */
    Object[] getParams();

    /**
     * Gets the method being invoked on the bean.
     * 
     * @return {@link Method}
     */
    Method getInvokingMethod();

    /**
     * Proceed the invocation chain or calls the method if this is the last
     * element on the chain.
     * 
     * The return Object from this method will be return to the client calling
     * the method through the proxy and if the types are incompatible, a
     * ClassCastException will be thrown at the client.
     * 
     * @return Object the return type
     * @throws Throwable
     *             if a Throwable is thrown.
     */
    Object proceed() throws Throwable;

    /**
     * Returns the proxy object on witch this method was invoked.
     * 
     * @return {@link Object}
     */
    Object getProxyObject();
}
